/*
 * @Author: xuetao 3168581151@qq.com
 * @Date: 2025-02-16
 * @LastEditors: xuetao 3168581151@qq.com
 * @LastEditTime: 2025-02-27
 * @Description: 
 */
import 'package:chat_client/config/api_config.dart';
import 'package:chat_client/widgets/c_square_avatar.dart';
import 'package:flutter/material.dart';

class ProfileCard extends StatelessWidget {
  final String name;
  final String account;
  final String location;
  final String avatarUrl;
  final Color? accentColor;

  ProfileCard({
    super.key,
    required this.name,
    required this.account,
    required this.location,
    required this.avatarUrl,
    Color? accentColor,
  }) : accentColor = accentColor ?? const Color(0xFF5A6A91).withAlpha(25);

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);

    return Card(
      margin: EdgeInsets.all(12),
      color: Colors.white,
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
      child: Padding(
        padding: EdgeInsets.symmetric(vertical: 16, horizontal: 20),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            // 头像区域
            Stack(
              children: [
                SquareAvatar(
                  size: 100,
                  backgroundColor: accentColor,
                  imageSource: AppConfig.baseUrl + avatarUrl,
                ),
                Positioned(
                  bottom: 0,
                  right: 0,
                  child: Container(
                    padding: EdgeInsets.all(4),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      shape: BoxShape.circle,
                      boxShadow: [
                        BoxShadow(color: Colors.black12, blurRadius: 4)
                      ],
                    ),
                    child: Icon(Icons.female, size: 20, color: Colors.orange),
                  ),
                ),
              ],
            ),
            SizedBox(width: 24),
            // 信息区域
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    name,
                    style: theme.textTheme.headlineSmall?.copyWith(
                      fontWeight: FontWeight.w600,
                      color: Colors.grey[800],
                    ),
                  ),
                  SizedBox(height: 8),
                  _buildInfoRow('账号：', account),
                  SizedBox(height: 4),
                  _buildInfoRow('地区：', location),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

  // 构建信息行组件
  Widget _buildInfoRow(String label, String value) {
    return RichText(
      text: TextSpan(
        style: TextStyle(
          fontSize: 16,
          color: Colors.grey[600],
          height: 1.4,
        ),
        children: [
          TextSpan(text: label, style: TextStyle(fontWeight: FontWeight.w500)),
          TextSpan(text: value),
        ],
      ),
    );
  }
}
